package com.seal.tsms.system.entity;

import com.seal.tsms.base.entity.BaseEntity;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;
import java.util.jar.Attributes;

/**
 * Created by seal.jing on 2016/1/5.
 */
@Entity
@Table(name = "SYS_RESOURCE")
public class SystemResource extends BaseEntity {
    private String name;
    private String description;
    private String uri;
    //private String type;
    private int statu;
    private SystemResource parent;
    private Set<SystemResource> children=new HashSet<SystemResource>();
    private Set<ResourceRole> resourceRoles=new HashSet<ResourceRole>();


    @Column(name = "RESOURCE_NAME")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Column(name = "RESOURCE_DESCRIPTION")
    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @Column(name = "RESOURCE_URI")
    public String getUri() {
        return uri;
    }

    public void setUri(String uri) {
        this.uri = uri;
    }

    @Column(name = "RESOURCE_STATU")
    public int getStatu() {
        return statu;
    }

    public void setStatu(int statu) {
        this.statu = statu;
    }

    @ManyToOne()
    @JoinColumn(name = "RESOURCE_PARENT_ID")
    public SystemResource getParent() {
        return parent;
    }

    public void setParent(SystemResource parent) {
        this.parent = parent;
    }

    @OneToMany(cascade = CascadeType.ALL,mappedBy = "parent")
    public Set<SystemResource> getChildren() {
        return children;
    }

    public void setChildren(Set<SystemResource> children) {
        this.children = children;
    }

    @OneToMany(cascade = CascadeType.ALL,mappedBy = "resource")
    public Set<ResourceRole> getResourceRoles() {
        return resourceRoles;
    }

    public void setResourceRoles(Set<ResourceRole> resourceRoles) {
        this.resourceRoles = resourceRoles;
    }
}
